package com.yequan.exe.business;

import com.yequan.exe.core.annotation.ExeService;
import com.yequan.exe.core.handler.AbstractExeHandler;
import com.yequan.exe.core.ExeExecutorExtListener;
import com.yequan.pojo.BaseCalcInfo;
import com.yequan.pojo.CalcData;
import com.yequan.pojo.ExeInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yq
 * @date 2020/09/29
 */
@ExeService("db2bpaCalcService")
public class Db2BpaExeHandler extends AbstractExeHandler implements ExeExecutorExtListener {

    @Override
    public void combineCommand(CalcData calcData) {
        List<String> command = new ArrayList<>();
        ExeInfo exeInfo = calcData.getExeInfo();
        BaseCalcInfo baseCalcInfo = calcData.getBaseCalcInfo();
        command.add(baseCalcInfo.getExeRootPath() + exeInfo.getExeName());
        command.add(exeInfo.getExeName());
        command.add(exeInfo.getLogPath());
        exeInfo.setCommand(command);
    }

    @Override
    public ExeExecutorExtListener getExeExecutorListener() {
        return this;
    }

    @Override
    public void afterExecuteExt(CalcData calcData, int result) {
        System.out.println("db2bpaCalcService 执行完成: 结果为" + result);
    }
}
